﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimeSolve
{
    public class UpdateData
    {
        List<IDataUpdate> updatedFlag = new List<IDataUpdate>();
        public void start(IDataUpdate parentPage)
        {
            foreach (IDataUpdate updated in updatedFlag)//检查是否已更新过，避免重复
            {
                if (ReferenceEquals(parentPage, updated))
                {
                    return;
                }
            }
            List<IDataUpdate> childrens = parentPage.updateAndGetChildren();
            updatedFlag.Add(parentPage);
            if (childrens != null)
            {
                foreach (IDataUpdate children in childrens)
                {
                    if (children != null)
                    {
                        start(children);
                    }
                }
            }
        }
    }
}
